# Environment
PROJECT=Aolis
V_MAJ=0
V_MIN=0
V_REL=0
VERSION=${V_MAJ}.${V_MIN}.${V_REL}

# Files & folders
SRC=src
INCL=include
EXE=toa${EXE_SUF}
OBJ= \
	main.o object_base.o sprite.o object_sprited.o entity.o entity_static.o \
	entity_animated.o entity_active.o character.o

# SDL2
SDL=
SDL2_TEST=sdl2-config --version
SDL_CXXFLAGS=`sdl2-config --cflags`
SDL_LDFLAGS=`sdl2-config --libs`

# Compiling
CC=g++
CFLAGS=-c -Wall -O2
CXXFLAGS=${CFLAGS}

# Linking
LIBS=-lSDL2main -lSDL
LDFLAGS=-s ${SDL_LDFLAGS}

all: sdltest ${OBJ}
	${CC} ${LDFLAGS} main.o -o ${EXE} ${LIBS}

main.o: ${SRC}/main.cpp ${INCL}/main.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/main.cpp

object_base.o: ${SRC}/object_base.cpp ${INCL}/object_base.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/object_base.cpp

sprite.o: ${SRC}/sprite.cpp ${INCL}/sprite.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/sprite.cpp

object_sprited.o: ${SRC}/object_sprited.cpp ${INCL}/object_base.h ${INCL}/sprite.h ${INCL}/object_sprited.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/object_sprited.cpp

entity.o: ${SRC}/entity.cpp ${INCL}/entity.h ${INCL}/object_sprited.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/entity.cpp

entity_static.o: ${SRC}/entity_static.cpp ${INCL}/entity_static.h ${INCL}/entity.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/entity_static.cpp

entity_animated.o: ${SRC}/entity_animated.cpp ${INCL}/entity_animated.h ${INCL}/entity.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/entity_animated.cpp

entity_active.o: ${SRC}/entity_active.cpp ${INCL}/entity_active.h ${INCL}/entity_animated.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/entity_active.cpp

character.o: ${SRC}/character.cpp ${INCL}/character.h ${INCL}/entity_active.h
	${CC} ${CXXFLAGS} -I${INCL} ${SRC}/character.cpp

sdltest:
	@echo "Testing for SDL2..."
	@${SDL2_TEST} && (echo "Found SDL version `${SDL2_TEST}`") || (echo "SDL2 not found... aborting"; exit 1)

clean:
	rm -rf *.o ${EXE}

install: all
	@echo "Installing in..."
	@echo "No instructions for installing yet!"
